<form class="layui-form" action="/version/add">
    <div class="layui-form-item">
        <label class="layui-form-label">版本号</label>
        <div class="layui-input-inline">
            <input type="text" name="version_num" lay-verify="required" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">终端类型</label>
        <div class="layui-input-inline">
            <select name="terminal_type" lay-verify="required">
                <option value="member">会员</option>
                <option value="proxy">代理</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">APP类型</label>
        <div class="layui-input-block">
            <input type="radio" name="app_type" value="android" title="android" checked>
            <input type="radio" name="app_type" value="ios" title="ios">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">下载地址</label>
        <div class="layui-input-inline">
            <input type="text" name="download_url" lay-verify="required" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">更新内容</label>
        <div class="layui-input-inline">
            <textarea name="update_content" class="layui-textarea" lay-verify="required"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">更新类型</label>
        <div class="layui-input-block">
            <input type="radio" name="update_way" value="forced"
                   title="强制更新" checked>
            <input type="radio" name="update_way" value="autonomous"
                   title="自主更新">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="<?= Yii::$app->request->csrfParam ?>"
                   value="<?= Yii::$app->request->csrfToken ?>">
            <button class="layui-btn" lay-submit lay-filter="submit-btn">保存</button>
        </div>
    </div>
</form>
<script>
    layui.use(['layer', 'form'], function () {
        var layer = layui.layer,
            form = layui.form();
        form.on('submit(submit-btn)', function (data) {
            var loading = layer.load(0, {
                shade: <?=Yii::$app->params['layui_shade']?>,
                time: <?=Yii::$app->params['layui_time']?>});
            $.post(data.form.action, data.field, function (rs) {
                layer.msg(rs.msg);
                if (rs.code === 0) {
                    setTimeout(function () {
                        window.location.href = rs.redirect;
                    }, <?=Yii::$app->params['layui_set_timeout']?>);
                }
                layer.close(loading);
            }, 'json');
            return false;
        });
    });
</script>